package com.singfan.core.dao.database.impl;

import com.singfan.common.db.DaoBaseGeneric;
import com.singfan.core.dao.database.IBarberHairServiceDao;
import com.singfan.core.dao.database.model.BarberHairService;
import org.springframework.stereotype.Repository;

/**
 *
 * Author: hansonghe
 * Date: 2015-08-19 12:12
 * Desc:
 */
@Repository
public class BarberHairServiceDaoImpl extends DaoBaseGeneric<BarberHairService> implements IBarberHairServiceDao {
    @Override
    protected String getTableName(Object hashKey) {
        return tableNameBase;
    }

    @Override
    protected String getDatabaseId(Object hashKey) {
        return "app_1";
    }

    @Override
    public void create(BarberHairService barberHairService) {
        insertWithAutoIncrement(null, barberHairService);
    }

    @Override
    public void updateShopHairServiceId(long shopId, int serviceType, int shopHairServiceId) {
        String sql = "UPDATE " + getTableName(null) + " SET shop_hair_service_id=? WHERE shop_id=? AND service_type=?";
        execute(null, sql, shopHairServiceId, shopId, serviceType);
    }
}
